home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: Test.c
- *
- * Licensing: This code may be used without fees provided that proper
- * copyright notice given.
- *
- * History: 1.0.0 RSM 93-11-29 Created first version
- *
- * ©1993 One Step Beyond
- */
-
- #ifdef THINK_C
- # include <MacHeaders>
- #else
- # include <Dialogs.h>
- # include <Fonts.h>
- # include <Memory.h>
- # include <Menus.h>
- # include <SegLoad.h>
- #endif
- #include "HotKeys.h"
-
- enum{
- iQuitBtn = 1,
- iSetBtn,
- iClearBtn,
- iHotKeyDUI
- };
-
-
- void Inits( void );
- void GetDItemRect( DialogPtr, short, Rect* );
- void SetDUserItem( DialogPtr, short, void* );
- pascal void HotKeyDUI( DialogPtr, short );
-
-
- HotKey gHotKey = {0,0,0,0};
-
-
- main()
- {
- DialogPtr dp;
- short hit;
-
- Inits();
-
- dp = GetNewDialog( 128, NULL, (GrafPtr)-1L );
- SetPort( dp );
- SetDUserItem( dp, iHotKeyDUI, &HotKeyDUI );
-
- do{
- ModalDialog( NULL, &hit );
- switch( hit ){
- case iSetBtn:
- SetHotKeyDlog( &gHotKey );
- HotKeyDUI( dp, iHotKeyDUI );
- break;
- case iClearBtn:
- ClearHotKey( &gHotKey );
- HotKeyDUI( dp, iHotKeyDUI );
- break;
- }
- }while( hit != iQuitBtn );
-
- DisposeDialog( dp );
- ExitToShell();
- }
-
-
- pascal void
- HotKeyDUI( DialogPtr dp, short item )
- {
- Rect bounds;
-
- GetDItemRect( dp, item, &bounds );
-
- // draw the frame
-
- PenNormal();
- FrameRect( &bounds );
- InsetRect( &bounds, 1, 1 );
- EraseRect( &bounds );
- DrawHotKey( &gHotKey, &bounds );
- }
-
-
- void
- Inits()
- {
- MaxApplZone();
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( NULL );
- InitCursor();
- }
-
-
- void
- SetDUserItem( DialogPtr dp, short itemID, void* duiProc )
- {
- Handle dumH;
- short dumSt;
- Rect dumR;
-
- GetDItem( dp, itemID, &dumSt, &dumH, &dumR );
- SetDItem( dp, itemID, dumSt, duiProc, &dumR );
- }
-
-
- void
- GetDItemRect( DialogPtr dp, short itemID, Rect *r )
- {
- Handle dumH;
- short dumSt;
-
- GetDItem( dp, itemID, &dumSt, &dumH, r );
- }
-